home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0130_The Game of Frogger.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  50.8 KB  |  1,333 lines

  1. { PLEASE NOTE ::  THE CREATE TILE PROGRAM NEEDED IS ATTACHED AT THE
  2.   BOTTOM !! }
  3.  
  4.  
  5. PROGRAM Frogger;
  6.  
  7. {Frogger version 0.90, Copyright 1995-1996 Gamefreak (AKA Jonas Maebe)}
  8. {Send comments to Jonas Maebe, 2:292/624.7 (Fidonet) or in the        }
  9. {internatial Fidonet Pascal confernce.                                }
  10. {Hereby I give this code to the freeware circuit, which implies that  }
  11. {evryone can use this code in ANY program, as long as I receive the   }
  12. {applicable credit(s).                                                }
  13. {I am in NO way responsible for any kind of damage directly or        }
  14. {indirectly caused by this program (just to be safe :)                }
  15.  
  16. {$g+,a+,r-,s-,i-,x+,n-,e-}
  17. {$m 8000, 0 ,655360}
  18.  
  19. {NEVER enable range checking ($R+), because it'll crash the computer.}
  20. {I don't know why, but I guess it has something to do with the move386}
  21. {procedure.}
  22.  
  23. {$ifdef ver70}
  24. {$q-}
  25. {$endif}
  26.  
  27. {*define p386}       {replace the '*' by a '$' to speed up the code}
  28.                      {somewhat if you have a 386 instead of a 486 or up.}
  29.                      {Probably not noticable, but who cares? :)}
  30. {$define slow}       {replace the '*' by a '$' to slow everything down,}
  31.                      {necessary when playing on a VLB/PCI videocard}
  32.  
  33. {*define invincible} {Have a wiiiiiild guess :)}
  34.  
  35. {*define idspispopd} {Remeber Doom? Of course you do!}
  36.                      {Ever cheated? Of course you did! :)}
  37.                      {BTW: pretty useless if not combined with the above one}
  38.  
  39. TYPE position = RECORD
  40.                      x,y:WORD
  41.                END;
  42.      big_tile = ARRAY[0..15,0..15] of BYTE;
  43.      small_tile = ARRAY[0..9,0..9] of BYTE;
  44.      Virscreen = Array [1..64000] of byte;
  45.      VirPtr = ^Virscreen;
  46.      treetype = (left,middle,right);
  47.      TturtleDepth = (up, med, down, under);
  48.  
  49. CONST retrace = 3; treemid1 = 4; treemid2 = 2; noftree1 = 2; noftree2 = 3;
  50.       car1y: word = 163; car2y: word = 147; car3y: word = 131;
  51.       car4y: word = 115; rightclip = 263; leftclip = 1;
  52.       treey: ARRAY[1..2] of WORD = (16*4+3, 16*2+3);
  53.       noftrees: ARRAY[1..2] of WORD = (noftree1, noftree2);
  54.       turtley: ARRAY[1..3] of WORD = (16*5+3, 16*3+3, 16+3);
  55.       waterinc: ARRAY[1..5] of INTEGER = (1,-1,2,1,-1);
  56.       frogtop: ARRAY[1..6] of BOOLEAN = (false,false,false,false,false,false);
  57.       keyb: word = 8;  stop: boolean = false;  lives: byte = 4;
  58.       car1pos: ARRAY[0..2,0..2] of INTEGER =
  59.                ((259,236,213),(170,147,123),(78,55,32));
  60.       car2pos: ARRAY[0..2,0..2] of INTEGER =
  61.                ((259,237,215),(167,145,123),(73,51,29));
  62.       car3pos: ARRAY[0..2] of WORD = (262,173,84);
  63.       car4pos: ARRAY[0..2,0..2] of INTEGER =
  64.                ((257,234,211),(167,144,121),(73,50,27));
  65.       turtlepos: ARRAY[1..3,0..2,0..2] of INTEGER =
  66.                (((257,244,231),(167,154,141),(73,60,47)),
  67.                 ((231,243,255),(141,153,165),(47,59,71)),
  68.                 ((231,244,257),(141,154,167),(47,60,73)));
  69.       tree1pos: ARRAY[1..2,1..(treemid1+2)] of WORD =
  70.               ((12,22,32,42,52,62),(150,160,170,180,190,200));
  71.       tree2pos: ARRAY[1..3,1..(treemid2+2)] of WORD =
  72.               ((56,46,36,26),(147,137,127,117),(238,228,218,208));
  73.       TurtleDepth: TTurtleDepth = up; TurtleDepthCount: WORD = 0;
  74.       cyclecount: BYTE = retrace; fpstime1 : LONGINT = 0;
  75.       fpstime2: LONGINT = 0; frames: LONGINT = 0;
  76.       CTurtleDepth: ARRAY[1..7] of TturtleDepth = (up, med, down, under,
  77.                                                   down, med, up);
  78.  
  79. VAR frogpos: position;
  80.     pall: ARRAY[0..255,0..2] OF BYTE;
  81.     grass, water: big_tile;
  82.     ch: CHAR;
  83.     Virscr, background : VirPtr;
  84.     Vaddr, backaddr  : word;
  85.     savedi, savecx: WORD;
  86.     frog,car1,car2,car3,car4,turtle,turtle2: small_tile;
  87.     tree: ARRAY[treetype] of small_tile;
  88.    {turtle dive vars}
  89.     TurtleDo1Le, TurtleDo2Le: Small_tile;
  90.     Time: WORD;
  91. {now some arrays which hold the offsets of the sprites}
  92. CONST treeofs: ARRAY[0..2] of WORD = (ofs(tree[left]),ofs(tree[middle]),
  93.                                       ofs(tree[right]));
  94.       TurtleOfs: ARRAY[1..3] OF WORD = (ofs(turtle), ofs(TurtleDo1Le),
  95.                                         ofs(TurtleDo2Le));
  96.  
  97. FUNCTION keypressed: BOOLEAN;
  98. INLINE($b4/$01/$cd/$16/$b0/$00/$74/$02/$fe/$c0);
  99.      {mov ah,1;int $16;mov al,0;jnz $+2;inc al}
  100.  
  101. FUNCTION readkey: CHAR;
  102. INLINE($b4/$10/$cd/$16/$88/$e0);
  103.    {mov ah,$10;int $16;mov al, ah}
  104.  
  105. {Sound and nosound are asm-translations of the Pascal code found in PCGPE10}
  106.  
  107. procedure Sound(frequency : word);
  108. inline
  109. ($ba/$12/$00/$b8/$dd/$34/  $59/    $f7/$f1/  $89/$c3/   $b0/$b6/
  110. {mov dx, $12;mov ax, $34dd;pop cx; div cx; mov bx, ax;mov al, $b6}
  111.   $e6/$43/   $88/$d8/    $e6/$42/   $88/$f8/   $e6/$42/    $e4/$61/
  112. {out $43, al;mov al,bl;out $42,al;mov al, bh;out $42, al;in al, $61}
  113.   $0c/$03/ $e6/$61);
  114. {or al, 3;out $61, al}
  115.  
  116. procedure NoSound;
  117. INLINE($E4/$61/ $24/$FC/     $E6/$61);
  118.    {in al, $61; and al, $fc; out $61, al}
  119.  
  120. PROCEDURE lawn(y:word);      {draw the lawn :)}
  121. VAR number,row,column:BYTE;
  122.           BEGIN
  123.                FOR number := 0 to 16 DO
  124.                    FOR row := 0 to 15 DO
  125.                        FOR column := 0 to 15 DO
  126.                            MEM[vaddr: (y+row) SHL 8 + (y+row) shl
  127. 6+column+number *16+1] := grass[row,column]          END;
  128.  
  129. PROCEDURE drawopaqueright;  {draw a sprite without preserving the}
  130. ASSEMBLER;                  {background, clipping the right side}
  131. ASM
  132.    sub dl, dl             {dx holds y * 256}
  133.   @loop:
  134.    xor cx, cx
  135.                           {di holds x-coord of car}
  136.    cmp di, rightclip      {needs clipping?}
  137.    jle @no_clip           {if pos <= clip-coord, don't clip}
  138.    mov cl, 10             {cx := 10}
  139.    sub cx, di             {cx = 10 - x-coord}
  140.    add cx, rightclip      {cx := 10 - x-coord + clip const = 10 - clippixels}
  141.    mov savecx, cx         {saveguard cx already}
  142.   @no_clip:
  143.    add di, dx
  144.    shr dx, 2
  145.    add di, dx             {di := y * 320 + x}
  146.    shl dx, 2              {dx is again y * 256}
  147.                           {ds:si already points to the car's sprite}
  148.    mov ah, 10             {repeat for 10 lines}
  149.   @drawcar:
  150.    or cx, cx              {check whether clipping is needed}
  151.    jnz @clip              {if it is, goto clip-drawing}
  152.    db $66; movsw
  153.    db $66; movsw
  154.    movsw                  {move car data to the virtual screen}
  155.    jmp @nextrow
  156.   @clip:
  157.    mov savedi, di
  158.    rep movsb              {move part of sprite to screen}
  159.    mov cx, savecx         {restore cx}
  160.    sub di, [bx]           {di - x-coord of car}
  161.    sub di, cx             {di - cx, to cancel effect of rep movsb}
  162.    inc di                 {di + 1 -> now points to (1,sprite-y)}
  163.    sub cx, 10
  164.    neg cx                 {cx = x-coord - clipconst}
  165.    rep movsb              {move remaining pixels to the beginning of line}
  166.    mov di, savedi         {restore original di}
  167.    mov cx, savecx         {and cx}
  168.    add di, 10             {di now points to (x-coord+10,car3y)}
  169.   @nextrow:
  170.    add di, 310           {increase di by 310 to let it point to next line}
  171.    dec ah                 {decrease line counter,}
  172.    jnz @drawcar           {if not 0, draw next line}
  173. END;
  174.  
  175. PROCEDURE drawtransparentright; {draw a sprite keeping the uncovered back-}
  176. ASSEMBLER;                      {ground, with clipping on the right side}
  177. ASM
  178.    xor dl, dl             {dx holds y * 256}
  179.   @loop:
  180.    xor cx, cx
  181.                           {di holds x-coord of tree}
  182.    cmp di, rightclip      {needs clipping?}
  183.    jle @no_clip           {if pos <= clip-coord, don't clip}
  184.    mov cl, 10             {cx := 10}
  185.    sub cx, di             {cx = 10 - x-coord}
  186.    add cx, rightclip      {cx := 10 - x-coord + clip const = 10 - clippixels}
  187.    mov savecx, cx         {saveguard cx already}
  188.   @no_clip:
  189.    add di, dx
  190.    shr dx, 2
  191.    add di, dx             {di := y * 320 + x}
  192.    shl dx, 2              {dx is again y * 256}
  193.                           {ds:si already points to the tree's sprite}
  194.    mov ah, 10             {repeat for 10 lines}
  195.   @drawtree:
  196.    or cx, cx              {check whether clipping is needed}
  197.    jnz @clip              {if it is, goto clip-drawing}
  198.    mov cx, 10             {move tree data to the virtual screen}
  199.   @nocliploop:
  200.    dec cx
  201.    js @noclipdone
  202. {$ifdef p386}
  203.    lodsb
  204. {$else}
  205.    mov al, [si]
  206.    inc si
  207. {$endif}
  208.    inc di
  209.    or al, al
  210.    jz @nocliploop
  211.    mov es:[di-1], al
  212.    jmp @nocliploop
  213.   @noclipdone:
  214.    xor cx, cx
  215.    jmp @nextrow
  216.   @clip:
  217.    mov savedi, di
  218. {  rep movsb              {move line of sprite to screen}
  219.    inc cx                 {the following part is the same as rep movsb,}
  220.   @cliploop:              {except that is soes not overwrite the background}
  221.    dec cx                 {where it's not covered by a sprite}
  222.    jz @outcliploop
  223.    lodsb
  224.    inc di
  225.    or al, al
  226.    jz @cliploop
  227.    mov es:[di-1], al
  228.    jmp @cliploop
  229.   @outcliploop:
  230.    sub di, [bx]           {di - x-coord of car}
  231.    mov cx, savecx         {restore cx}
  232.    sub di, cx             {di - cx, to cancel effect of rep movsb}
  233.    inc di                 {di + 1 -> now points to (1, sprite-y)}
  234.    sub cx, 10
  235.    neg cx                 {cx = x-coord - clipconst}
  236.    dec di
  237. {   rep movsb          {move remaining pixels to the beginning of the line}
  238.    inc cx
  239.   @cliploop2:
  240.    dec cx
  241.    jz @outcliploop2
  242.    inc di
  243. {$ifdef p386}
  244.    lodsb
  245. {$else}
  246.    mov al, [si]
  247.    inc si
  248. {$endif}
  249.    or al, al
  250.    jz @cliploop2
  251.   mov es:[di], al
  252.   @noclipdraw2:
  253.    jmp @cliploop2
  254.   @outcliploop2:
  255.    mov di, savedi         {restore original di}
  256.    mov cx, savecx         {and cx}
  257.    add di, 10             {di now points to (x-coord+10,car3y)}
  258.   @nextrow:
  259.    add di, 310        {increase di by 310 to let it point to the next line}
  260.    dec ah                 {decrease line counter,}
  261.    jnz @drawtree          {if not 0, draw next line}
  262. END;
  263.  
  264. PROCEDURE drawopaqueleft;   {draw a sprite without preserving the}
  265. ASSEMBLER;                  {background, clipping on the left side}
  266. ASM
  267.    sub dl, dl             {dx holds y * 256}
  268.   @loop:
  269.    xor cx, cx
  270.                           {di holds x-coord of car}
  271.    cmp di, leftclip       {needs clipping?}
  272.    jge @no_clip           {if pos >= clip-coord, don't clip}
  273.    mov cx, di             {cx := x-coord}
  274.    dec cx
  275.    neg cx                 {because it's negative, make it positive}
  276.    mov savecx, cx         {saveguard cx already}
  277.   @no_clip:
  278.    add di, dx
  279.    shr dx, 2
  280.    add di, dx             {di := y * 320 + x}
  281.    shl dx, 2              {dx is again y * 256}
  282.                           {ds:si points to the car's sprite}
  283.    mov ah, 10             {repeat for 10 lines}
  284.   @drawcar:
  285.    or cx, cx              {check whether clipping is needed}
  286.    jnz @clip              {if it is, goto clip-drawing}
  287.    db $66; movsw
  288.    db $66; movsw
  289.    movsw                  {move sprite data to the virtual screen}
  290.    jmp @nextrow
  291.   @clip:
  292.    mov savedi, di         {saveguard di}
  293. {now, first the part on the right side of the screen is drawn, because}
  294. {that's where the first pixels have to be put}
  295.    add di, rightclip + 9 {let it point to "end-of-line" + x-coord (this last}
  296.                           {one is negative, so: "end-of-line" - x-coord)}
  297.    rep movsb              {move part of sprite to screen}
  298.    mov cx, savecx         {restore cx}
  299.    sub di, rightclip + 9  {di points to the beginning of the line}
  300.    sub cx, 10
  301.    neg cx                 {cx = number of pixels left of the car}
  302.    rep movsb              {move remaining pixels to the beginning of the line}
  303.    mov di, savedi         {restore original di}
  304.    mov cx, savecx         {and cx}
  305.    add di, 10             {di now points to (x-coord+10,car3y)}
  306.   @nextrow:
  307.    add di, 310            {increase di by 310 so it points to the next line}
  308.    dec ah                 {decrease line counter,}
  309.    jnz @drawcar           {if not 0, draw next line}
  310. END;
  311.  
  312. PROCEDURE drawtransparentleft;  {draw a sprite keeping the uncovered back-}
  313. ASSEMBLER;                      {ground, with clipping of the right side}
  314. ASM
  315.    sub dl, dl             {dx holds y * 256}
  316.   @loop:
  317.    xor cx, cx
  318.                           {di holds x-coord of car}
  319.    cmp di, leftclip       {needs clipping?}
  320.    jge @no_clip           {if pos >= clip-coord, don't clip}
  321.    mov cx, di             {cx := x-coord}
  322.    dec cx
  323.    neg cx                 {because it's negative, make it positive}
  324.    mov savecx, cx         {saveguard cx already}
  325.   @no_clip:
  326.    add di, dx
  327.    shr dx, 2
  328.    add di, dx             {di := y * 320 + x}
  329.    shl dx, 2              {dx is again y * 256 => ready for use with a}
  330.                           {succeeding call using the same y-value}
  331.                           {ds:si points to the car's sprite}
  332.    mov ah, 10             {repeat for 10 lines}
  333.   @drawcar:
  334.    or cx, cx              {check whether clipping is needed}
  335.    jnz @clip              {if it is, goto clip-drawing}
  336.                           {move car data to the virtual screen}
  337.    mov cx, 10             {move tree data to the virtual screen}
  338.   @nocliploop:
  339.    dec cx
  340.    js @noclipdone
  341. {$ifdef p386}
  342.    lodsb
  343. {$else}
  344.    mov al, [si]
  345.    inc si
  346. {$endif}
  347.    inc di
  348.    or al, al
  349.    jz @nocliploop
  350. {$ifdef p386}
  351.    dec di
  352.    stosb
  353. {$else}
  354.    dec di
  355.    mov es:[di], al
  356.    inc di
  357. {$endif}
  358.    jmp @nocliploop
  359.   @noclipdone:
  360.    xor cx, cx
  361.    jmp @nextrow
  362.   @clip:
  363.    mov savedi, di         {saveguard di}
  364.    add di, rightclip + 9  {let it point to "end-of-line" + x-coord. This}
  365.                           {last one is negative, so: "end-of-line" - x-coord}
  366. {   rep movsb             {move part of sprite to screen}
  367.    inc cx
  368.   @cliploop:
  369.    dec cx
  370.    jz @outcliploop
  371. {$ifdef p386}
  372.    lodsb
  373. {$else}
  374.    mov al, [si]
  375.    inc si
  376. {$endif}
  377.    inc di
  378.    or al, al
  379.    jz @cliploop
  380.    mov es:[di-1], al
  381.    jmp @cliploop
  382.   @outcliploop:
  383.    mov cx, savecx         {restore cx}
  384.    sub di, rightclip+10   {di points to the beginning of the line}
  385.    sub cx, 11
  386.    neg cx             {cx = number of pixels left of the car}
  387.                       {move remaining pixels to the beginning of the line}
  388.   @cliploop2:
  389.    dec cx
  390.    jz @outcliploop2
  391.    inc di
  392. {$ifdef p386}
  393.    lodsb
  394. {$else}
  395.    mov al, [si]
  396.    inc si
  397. {$endif}
  398.    or al, al
  399.    jz @cliploop2
  400.    mov es:[di], al
  401.    jmp @cliploop2
  402.   @outcliploop2:
  403.    mov di, savedi         {restore original di}
  404.    mov cx, savecx         {and cx}
  405.    add di, 10             {di now points to (x-coord+10,car3y)}
  406.   @nextrow:
  407.    add di, 310            {increase di by 310 to let it point}
  408.    dec ah                 {to the next line; decrease line}
  409.    jnz @drawcar           {counter, if not 0, draw next line}
  410. END;
  411.  
  412.  
  413. PROCEDURE river;        {draws the river}
  414. VAR number,row,column,riversize:BYTE;
  415.           BEGIN
  416.                FOR riversize := 0 to 1 DO
  417.                FOR number := 0 to 16 DO
  418.                    FOR row := 0 to 15 DO
  419.                        FOR column := 0 to 15 DO
  420.                            MEM[vaddr: (riversize*48+row+16) SHL 8 +
  421. (riversize*48+row+16) shl 6+column+number *16+1] :=
  422. water[row,column];               FOR number := 0 to 16 DO
  423.                    FOR row := 0 to 15 DO
  424.                        FOR column := 0 to 15 DO
  425.                            MEM[vaddr: (row+48) SHL 8 + (row+48) shl
  426. 6+column+number *16+1] :=                           water[row,column];
  427.                FOR riversize := 0 to 1 DO
  428.                FOR number := 0 to 16 DO
  429.                    FOR row := 0 to 15 DO
  430.                        FOR column := 0 to 15 DO
  431.                            MEM[vaddr: (riversize*48+row+32) SHL 8 +
  432. (riversize*48+row+32) shl 6+column+number *16+1] :=
  433. water[15-row,15-column]          END;
  434.  
  435. FUNCTION drawfrog: boolean;     {Draws the frog and returns true if a}
  436. ASSEMBLER;                      {collission occured}
  437. ASM
  438.    mov si, offset frog  {ds:si points to the frog picture}
  439.                         {di := x}
  440.    xor al, al           {al := 0}
  441.                         {ah := y}
  442.    cmp ah, 6 * 16       {= "hight" of road}
  443.    jb @noroad
  444.    xor bx, bx           {bx := 0}
  445.    cmp ah, 101          {is the frog on the road?}
  446.    jb @noroad
  447.    cmp ah, 178
  448.    ja @noroad           {if it is, set the and mask (bh) to 1, otherwise}
  449.    inc bh               {leave it 0}
  450.   @noroad:
  451.    add di, ax
  452.    shr ax, 2
  453.    mov cx, $a0b         {10 rows, 10 columns, but cl is decreased before the}
  454.                         {rest}
  455.    add di, ax           {di := y * 320 + x}
  456.  @loop:                 {of the code is executed}
  457.    dec cl               {decrease culomn counter}
  458.    jz @outloop          {cl = 0? -> goto the outer loop}
  459.    inc di               {di points to the nextpixel on screen}
  460.   {$ifdef p386}
  461.    lodsb                {load the next frogpixel in al}
  462.   {$else}
  463.    mov al, [si]         {load the next frogpixel in al}
  464.    inc si
  465.   {$endif}
  466.    or al, al            {test if it is zero}
  467.    jz @loop             {if it is, don't draw and go to the next pixel}
  468.    or bl, bl            {otherwise, check whether a collision has already}
  469.    jnz @nocolis         {occured; if so, do not check for it again}
  470.    cmp byte [es:di], 0  {check whether the background is zero (=black}
  471.    jz @nocolis          {if it is, no collission}
  472.    inc bl               {otherwise, set the and mask to 1}
  473.   @nocolis:
  474.    mov es:[di],al       {put the pixel in place}
  475.    jmp @loop            {and jump to the next one}
  476. @outloop:
  477.    mov cl, 11           {again 10 columns to put}
  478.    add di, 310          {di points to the next line (10 pixels + 310)}
  479.    dec ch               {decrease the row counter}
  480.    jnz @loop            {if not = 0 -> goto loop}
  481.    mov al, bl           {al (function result) = 1 if a collission occured}
  482.    and al, bh           {and it by bh; bh = 1 if the frog is on the road}
  483.                         {or IN the water, otherwise it's zero}
  484. END;
  485.  
  486. PROCEDURE Topwater(where: word); {draws the little 'lakes' (can't find a}
  487. VAR count, row, column: BYTE;    {better word for them :) at the top}
  488. BEGIN
  489.      FOR count := 1 TO 6 DO
  490.          FOR row := 0 to 14 DO
  491.              FOR column := 0 to 15 DO
  492.                  mem[where: 288+row * 256 + row * 64 + count*46 + column] :=
  493.                  random(10)+11
  494. END;
  495.  
  496.  
  497. PROCEDURE move386(source, dest: word);     {VERY FAST move routine!!!}
  498. INLINE( $fa/$8c/$da/  $07/   $1F   /$31/$f6/  $31/$ff/  $B9/$80/$3e/
  499.        {cli;mov dx,ds;pop es;pop ds;xor si,si;xor di,di;mov cx,16000}
  500.         $f3/$66/$a5/$8e/ $da/  $fb);
  501.        {rep movsd;  mov ds,dx; sti}
  502.  
  503. PROCEDURE init;
  504. VAR f: file;
  505.     count, row, column: BYTE;
  506. LABEL grassloop, outgrassloop;
  507.  
  508. Procedure Getmem0(Var p: VirPtr);
  509. Type Ttemp = Array[1..16] of byte;
  510. Var temp: ^Ttemp;
  511.     b: byte;
  512. BEGIN
  513.      new(p);
  514.      If ofs(p^) <> 0 Then
  515.         Begin
  516.              b := 16 - lo(ofs(p^));
  517.              Dispose(p);
  518.              Getmem(temp, b);
  519.              new(p);
  520.              dispose(temp)
  521.         End
  522. End;
  523.  
  524. BEGIN
  525.      assign(f,'frogger.til');         {read the tiles into the vars}
  526.      reset(f,1);
  527.      IF ioresult <> 0 THEN
  528.         BEGIN
  529.              WRITELN;
  530.              WRITELN('Frogger.til not found. Run TileGen first.');
  531.              WRITELN;
  532.              HALT(2)
  533.         END;
  534.      BLOCKREAD(f,water,sizeof(water));      {read the sprites into the}
  535.      BLOCKREAD(f,grass,sizeof(grass));      {variables}
  536.      BLOCKREAD(f,frog,sizeof(frog));
  537.      BLOCKREAD(f,car1,sizeof(car1));
  538.      BLOCKREAD(f,car2,sizeof(car2));
  539.      BLOCKREAD(f,car3,sizeof(car3));
  540.      BLOCKREAD(f,car4,sizeof(car4));
  541.      BLOCKREAD(f,turtle,sizeof(turtle));
  542.      BLOCKREAD(f,tree[left],sizeof(tree[left]));
  543.      BLOCKREAD(f,tree[middle],sizeof(tree[middle]));
  544.      BLOCKREAD(f,tree[right],sizeof(tree[right]));
  545.      BLOCKREAD(f,pall,sizeof(pall));
  546.      BLOCKREAD(f,turtle2,sizeof(turtle2));
  547.      BLOCKREAD(f,TurtleDo1Le,sizeof(TurtleDo1Le));
  548.      BLOCKREAD(f,TurtleDo2Le,sizeof(TurtleDo2Le));
  549.      close(f);
  550.      ASM
  551.         mov ax,$13
  552.         int $10             {switch to graphics mode}
  553.         mov ah, 9
  554.         int $16             {get keyboard functionalities}
  555.         and al, 1000b       {get typematic delay/rate available?}
  556.         jz @no_get_rate
  557.         mov ax, $306        {if so, get it!}
  558.         int $16
  559.         mov keyb, bx        {and store it}
  560.        @no_get_rate:
  561.         mov ax, $305        {set the new rate/delay for the game}
  562.         xor bx, bx
  563.         int $16
  564.         cld         {clear direction flag -> all movsb/w/d are forward}
  565.      END;
  566.      If maxavail < 130000 THEN
  567.         BEGIN
  568.              Writeln;
  569.              Writeln('Not enough memory availeble for virtual screens...');
  570.              Writeln;
  571.              Halt(8)
  572.         End;
  573. {initialize virtual screens}
  574.      getmem0(virscr);           {to make sure the offset of both virtual}
  575.      getmem0(background);       {screens is 0}
  576.      vaddr := seg(virscr^);
  577.      backaddr := seg(background^);
  578.      ASM                          {clear screen}
  579.         mov es, vaddr
  580.         xor di, di
  581.         db $66; xor ax, ax
  582.         mov cx, 16000
  583.         db $66; rep stosw
  584.         {set the pallette}
  585.         mov dx, $3c8
  586.         out dx, al
  587.         mov si, offset pall
  588.         inc dx
  589.         mov cx, 256*3
  590.         rep outsb
  591.      END;
  592.      river;
  593.      lawn(0);
  594.      Topwater(vaddr);
  595.      lawn(6*16);
  596.      lawn(192-16);
  597.      randomize;
  598.      ASM
  599.         mov es, vaddr               {draw grass hanging over in}
  600.                                     {the water and on the road}
  601.         mov ax, $0302               {ah = counter, al = value to be}
  602.                                     {added to random color}
  603.         mov di, 16*320              {just below the little 'lakes' (still}
  604.                                     {haven't found the right word :)}
  605.         mov si, 6*16*320-320+273    {eol above the verge (='berm' in}
  606.                                     {Dutch)}
  607.        outgrassloop:
  608.         mov cx, 273                 {play field is 273 pixels wide}
  609.         grassloop:
  610.         push ax                      {save ax and cx since they're used}
  611.         push cx                      {in the random() function}
  612.      END;
  613.      count := random(9);
  614.      ASM
  615.         pop cx                      {nd restore the registers}
  616.         pop ax
  617.         mov dl, count               {get the random value in dl}
  618.         test dl, 1                  {if the random value is even, don't}
  619.         jz @nodraw                  {draw a pixel}
  620.         mov dh, 10                  {and get the highest color's number}
  621.                                     {that's green in dh}
  622.         cmp es:[di-320], dh         {compare the pixel on the previous}
  623.         ja @nodraw                  {line to green. If it's greater,}
  624.                                     {don't draw}
  625.         add dl, al                  {add 2 to the random value}
  626.         mov es:[di], dl             {put the pixel on four places,}
  627.         mov es:[si], dl             {in the game you can see where :)}
  628.         mov es:[di+6*16*320], dl
  629.         mov es:[si+5*16*320], dl
  630.        @nodraw:
  631.         inc di                      {adjust the screen offsets}
  632.         dec si
  633.         dec cx
  634.         jnz grassloop
  635.         add di, 47
  636.         sub si, 47
  637.         dec ah                      {make the grass grow max 3 pixels}
  638.         jnz outgrassloop
  639. {draw green border around the playfield}
  640.         xor di, di
  641.         mov al, 10
  642.         mov cl,192
  643.        @loop:
  644.         mov es:[di], al
  645.         mov es:[di+273],al
  646.         add di, 320
  647.         dec cl
  648.         jnz @loop
  649.      END;
  650.      move386(vaddr,backaddr);     {save the current screen as the background}
  651.      WITH frogpos DO              {set initial frogpos}
  652.           BEGIN
  653.                x:=260 div 2;
  654.                y:=179
  655.           END
  656. END;
  657.  
  658. label nocol;
  659.  
  660. BEGIN
  661.      init;
  662.      ASM
  663.         xor ax, ax        {get the begin time, used to decide when the}
  664.         mov es, ax        {turtles dive}
  665.         mov di, $46c
  666.         db $66; mov ax, es:[di]
  667.         db $66; mov word[fpstime1], ax
  668.         add ax, 18        {and add 18 (= 1 sec) to that time}
  669.         mov time, ax
  670.      END;
  671.      REPEAT
  672.            ASM
  673.               db $66; inc word[frames]
  674.               dec cyclecount            {decrease cyclecount}
  675.               jnz @nocycle              {if it isn't zero, don't cycle}
  676.               std                       {the pallette (water); set direction}
  677.               mov ax, ds                {flag to move backwards}
  678.               mov es, ax                {es := ds}
  679.               mov cyclecount, retrace   {reset cyclecout to 2}
  680.               mov si, offset pall + 54  {ds:si points to pall[20,0]}
  681.               mov bx, [si]              {save the red and green values in bx}
  682.               mov dl, [si+2]            {save the blue value in dl}
  683.               mov si, offset pall+19*3+1{ds:si points to pall[19,1]}
  684.               mov di, offset pall+20*3+1{es:di points to pall[20,1]}
  685.               mov cx, 6
  686.               db $66; rep movsw
  687.               movsw
  688.               movsb                     {move the pallette values}
  689.               add si,2                  {adjust the source index, I don't}
  690.                                         {really understand why, but it's}
  691.                                         {nessecary :)}
  692.               cld                       {clear the direction flag}
  693.               mov [si], bx              {restore the red, green}
  694.               mov [si+2], dl            {and blue values}
  695.                                         {restore it}
  696.              @nocycle:
  697.               xor ax, ax
  698.               mov es, ax
  699.               mov di, $46c
  700.               mov ax, es:[di]           {get the current time}
  701.               cmp time, ax              {compare it to the previous read time}
  702.               jnle @noturtledive        {not equal -> don't change depth of}
  703.               add ax, 18                {turtles}
  704.               mov time, ax              {save new time}
  705.               mov bx, TurtleDepthCount
  706.               inc bx
  707.               cmp bx, 8
  708.               jb @TurtleDepthCountOk
  709.               xor bx, bx
  710.              @TurtleDepthCountOk:
  711.               mov TurtleDepthCount, bx
  712.               mov al, [bx+offset CTurtleDepth]
  713.              {= mov al, CTurtleDepth[TurtleDepthCount]}
  714.               mov TurtleDepth, al       {set the new TurtleDepth}
  715.              @noturtledive:
  716.               mov es, vaddr             {es has been changed, so restore it}
  717. {draw cars}
  718.               mov bx, offset car1pos    {ds:bx points to pos of car1pos[0,0]}
  719.               mov al, 9                 {repeat for 9 cars}
  720.               mov dh, byte [car1y]      {y coords of car1 in dh}
  721.              @loop:
  722.               {$ifdef slow}
  723.               test byte[turtlepos],1    {If slow, only increase the car's}
  724.               jz @noinc1                {position once per 2 loops}
  725.               inc word [bx]             {increase the position of the car}
  726.              @noinc1:
  727.               {$else}
  728.               inc word [bx]             {increase the position of the car}
  729.               {$endif}
  730.               mov di, [bx]              {x-coord in di}
  731.               cmp di, 273               {check whether it's off screen}
  732.               jl @noreset               {if not, do not reset it's coords}
  733.               mov di, 1
  734.               mov word [bx], di         {otherwise set x-coord back to 1}
  735.              @noreset:                  {parameter are passed in regs}
  736.                                         {next car}
  737.               mov si, offset car1       {select which car should be drawn}
  738.               call drawopaqueright      {and call the drawcar procedure}
  739.               add bx, 2                 {let bx point to the x-coord of the}
  740.               dec al                    {decrease the car counter}
  741.               jnz @loop                 {if it's not zero, loop for the next}
  742.               mov bx, offset car2pos    {car; repeat the same for car2,}
  743.               mov al, 9                 {but decrease the position instead}
  744.              @loop1:                    {of increasing it}
  745.               {$ifdef slow}
  746.               dec word [bx]
  747.               {$else}
  748.               sub word [bx], 2
  749.               {$endif}
  750.               mov di, [bx]
  751.               cmp di, -9
  752.               jg @noreset1
  753.               mov di, 263
  754.               mov [bx], di
  755.              @noreset1:
  756.               mov dh, byte [car2y]
  757.               mov si, offset car2
  758.               push ax
  759.               call drawopaqueleft    {and call drawopaqueleft since the car}
  760.               pop ax
  761.               add bx, 2
  762.               dec al                    {moves from the righ to the left}
  763.               jnz @loop1
  764.               mov bx, offset car3pos    {and now for car3 (race cars), there}
  765.               mov al, 3                 {are only 3 of them, but the rest}
  766.               mov dh, byte [car3y]
  767.              @loop2:                    {is about the same as for car 1}
  768.               {$ifdef slow}
  769.               add word [bx], 2          {increase the position of the car}
  770.               {$else}
  771.               add word [bx], 3          {increase the position of the car}
  772.               {$endif}
  773.               mov di, [bx]
  774.               cmp di, 273
  775.               jl @noreset2
  776.               mov word [bx], 1
  777.               mov di, 1
  778.              @noreset2:
  779.               mov si, offset car3
  780.               call drawopaqueright
  781.               add bx, 2
  782.               dec al
  783.               jnz @loop2
  784.               mov bx, offset car4pos    {car4, same as car2 but decrease}
  785.               mov al, 9                 {only by one}
  786.               mov dh, byte [car4y]
  787.              @loop3:
  788.               {$ifdef slow}
  789.               test byte[turtlepos],1
  790.               jnz @noinc2
  791.               dec word [bx]             {decrease the position of the car}
  792.              @noinc2:
  793.               {$else}
  794.               dec word [bx]             {decrease the position of the car}
  795.               {$endif}
  796.               mov di, [bx]
  797.               cmp di, -9
  798.               jg @noreset3
  799.               mov di, 263
  800.               mov [bx], di
  801.              @noreset3:
  802.               mov si, offset car4
  803.               call drawopaqueleft
  804.               add bx, 2
  805.               dec al
  806.               jnz @loop3
  807.               mov al, 10
  808.               mov di, 320 * 114
  809.               mov cl, 10
  810. {Draw trees}
  811.               mov bx, offset tree1pos
  812.               mov dh, 16*4+3
  813.               xor ah, ah
  814.               mov al, noftree1
  815.              @treerow1:
  816.               push ax
  817.               mov si, word[offset treeofs] {si = offset of tree[left]}
  818.               inc word[bx]
  819.               mov di, [bx]
  820.               cmp di, 273
  821.               jl @treeok1
  822.               mov di,1
  823.               mov word[bx], di
  824.              @treeok1:
  825.            call drawtransparentright
  826.               xor ah, ah
  827.               mov al, treemid1 {ax := number of middle parts}
  828.              @drawmiddle:
  829.               add bx, 2
  830.               mov si, word[offset treeofs + 2] {si = offset of tree[middle]}
  831.               inc word[bx]
  832.               mov di, [bx]
  833.               cmp di, 273
  834.               jl @treeok2
  835.               mov di,1
  836.               mov word[bx], di
  837.              @treeok2:
  838.               call drawopaqueright
  839.               dec ax          {middle part counter, if not zero, draw another}
  840.               jnz @drawmiddle {middle part}
  841.               add bx, 2
  842.               mov si, word[offset treeofs + 4] {si = ofs(tree[right])}
  843.               inc word[bx]
  844.               mov di, [bx]
  845.               cmp di, 273
  846.               jl @treeok3
  847.               mov di,1
  848.               mov word[bx], di
  849.              @treeok3:
  850.            call drawopaqueright
  851.               pop ax
  852.               add bx, 2
  853.               dec ax
  854.               jnz @treerow1
  855. {second row of trees}
  856.               mov bx, offset tree2pos
  857.               mov dh, 16*2+3
  858.               xor ah, ah
  859.               mov al, noftree2
  860.              @treerow2:
  861.               push ax
  862.               mov si, word[offset treeofs+4]
  863.               dec word[bx]
  864.               mov di, [bx]
  865.               cmp di, -9
  866.               jg @tree2ok1
  867.               mov di,263
  868.               mov word[bx], di
  869.              @tree2ok1:
  870.            call drawopaqueleft
  871.               xor ah, ah
  872.               mov al, treemid2 {ax := number of middle parts}
  873.              @drawmiddle2:
  874.               add bx, 2
  875.               mov si, word[offset treeofs + 2]
  876.               dec word[bx]
  877.               mov di, [bx]
  878.               cmp di, -9
  879.               jg @tree2ok2
  880.               mov di,263
  881.               mov word[bx], di
  882.              @tree2ok2:
  883.            call drawopaqueleft
  884.               dec ax
  885.               jnz @drawmiddle2
  886.               add bx, 2
  887.               mov si, word[offset treeofs]
  888.               dec word[bx]
  889.               mov di, [bx]
  890.               cmp di, -9
  891.               jg @tree2ok3
  892.               mov di,263
  893.               mov word[bx], di
  894.              @tree2ok3:
  895.            call drawtransparentleft
  896.               pop ax
  897.               add bx, 2
  898.               dec ax
  899.               jnz @treerow2
  900. {Draw lowest row of 'turtles' :)}
  901.               mov bx, offset turtlepos
  902.               mov dh, [offset turtley]
  903. {              push bp} {not necessary to preserve bp *IN THIS PROGRAM*!}
  904.               {normally ALWAYS RESTORE IT OR YOU'LL GET IN BIG TROUBLE!}
  905.               {Even better: don't use it :)}
  906.               mov al, TurtleDepth
  907.               mov bp, ax
  908.               cmp bp, 3
  909.               je @nolowturtles
  910.               add bp, bp
  911.               add bp, offset TurtleOfs
  912.               mov ah, 9
  913.              @turtlesamerowloop:
  914.               mov si, [ds:bp]
  915.               dec word[bx]
  916.               mov di, [bx]
  917.               cmp di, -9
  918.               jg @turtleposok
  919.               mov di, 263
  920.               mov [bx], di
  921.              @turtleposok:
  922.               push ax
  923.               call drawtransparentleft
  924.               add bx, 2
  925.               pop ax
  926.               dec ah
  927.               jnz @turtlesamerowloop
  928.               jmp @noadjust
  929.              @nolowturtles:
  930.               mov ah, 9
  931.              @noturtlesamerowloop:
  932.               dec word[bx]
  933.               mov di, [bx]
  934.               cmp di, -9
  935.               jg @noturtleposok
  936.               mov di, 263
  937.               mov [bx], di
  938.              @noturtleposok:
  939.               add bx, 2
  940.               dec ah
  941.               jnz @noturtlesamerowloop
  942.              @noadjust:
  943. {draw two higher rows of turtles in one loop since they move in the same}
  944.               mov bp, 2                      {direction}
  945.              @turtlenewrowloop:
  946.               mov dh, [ds:offset turtley+bp]
  947.               mov ah, 9
  948.              @turtlesamerowloop2:
  949.               mov si, offset turtle2
  950.              @turtleslowpos:
  951.               inc word[bx]  {(*)}
  952.               inc word[bx]
  953.               mov di, [bx]
  954.               cmp di, 273
  955.               jl @turtleposok3
  956.               mov di, 1
  957.               mov [bx], di
  958.              @turtleposok3:
  959.               push ax
  960.               call drawtransparentright
  961.               add bx, 2
  962.               pop ax
  963.               dec ah
  964.               jnz @turtlesamerowloop2
  965.               mov ax, $9090 {(*): self modifying code: replace one of the}
  966.               mov word[cs:@turtleslowpos], ax {two inc's with nop's}
  967.               add bp, 2
  968.               cmp bp, 4 {if it's 4, only one row of turtles has been drawn}
  969.               je @turtlenewrowloop
  970.               mov ax, $07ff       {and restore the original inc}
  971.               mov word[cs:@turtleslowpos], ax
  972. {              pop bp}
  973. {draw frog}
  974.               mov di, frogpos.x
  975.               mov ah, byte [frogpos.y]
  976.               xor bx, bx
  977.               cmp ah, 6 * 16
  978.               ja @waterdone     {frog is on the road or in the grass}
  979.               cmp ah, 16
  980.               jb @top           {frog is on the top row, seperate check}
  981.              {@water:}
  982.               xor al, al
  983.               mov dx, ax
  984.               mov si, ax
  985.               shr dx, 2
  986.               add si, dx
  987.               add si, di
  988.               add si, 320*4+4   {es:[si] points to the middle of the frog}
  989.               mov dl, es:[si]
  990.               cmp dl, 11        {background color on that spot < blue?}
  991.               jb @nocollission  {yes, go to position adjustment}
  992.               cmp dl, 21        {background color on that spot > blue?}
  993.               ja @nocollission  {yes, go to position adjustment}
  994.               add si, 3
  995.               mov dl, es:[si]   {another check for water, but 3 pixels to}
  996.               cmp dl, 11        {the right}
  997.               jb @nocollission
  998.               cmp dl, 21
  999.               ja @nocollission
  1000.              @topcol:
  1001.               mov bx, $101      {this way drawfrog will return 'true' as}
  1002.               jmp @waterdone    {collission value}
  1003. {*}          @top:
  1004.               xor al, al
  1005.               mov dx, ax
  1006.               mov si, ax
  1007.               shr dx, 2
  1008.               add si, dx
  1009.               add si, di
  1010.               mov dl, es:[si+2] {es:[si] points near the upper left corner}
  1011.               cmp dl, 11        {of the frog}
  1012.               jb @topcol        {if it's water, it's ok, otherwise jump to}
  1013.               cmp dl, 21        {collission}
  1014.               ja @topcol
  1015.               mov dl, es:[si+9] {and check near the upper right corner}
  1016.               cmp dl, 11        {as well}
  1017.               jb @topcol
  1018.               cmp dl, 21
  1019.               ja @topcol
  1020.               mov si, di        {si = xpos of frog}
  1021.               mov cx, 5
  1022.               mov bx, offset frogtop
  1023.              @topcheck:         {check in which hole the frog landed}
  1024.               sub si, 46
  1025.               jle @posfound
  1026.               inc bx
  1027.               dec cl
  1028.               jnz @topcheck
  1029.              @posfound:
  1030.               cmp byte [bx], 0
  1031.               jnz @topcol
  1032.               mov byte [bx], 1
  1033.               mov frogpos.x, 130
  1034.               mov frogpos.y, 179
  1035.               mov cl, 6
  1036.               xor bx, bx
  1037.               mov es, backaddr
  1038.               jmp @waterdone
  1039.           @nocollission:
  1040.               mov bl, ah
  1041.               xor bh, bh   {bx holds the y-coords of the frog}
  1042.               shr bx, 3    {divide those by 16, every y-step = 16 pixels,}
  1043.                            {so for (water) row 5, bx becomes 5 etc}
  1044.               sub bx, 2    {adjust, because the upper row isn't counted in}
  1045.               add di, [offset waterinc + bx] {add the apprpriate pos-adjuster}
  1046.               or di, di    {check if we're at one of the screen edges}
  1047.               jz @undoinc  {if so, don't change the position}
  1048.               cmp di, 261
  1049.               jg @undoinc
  1050.               mov [frogpos.x], di
  1051.               xor bx, bx          {set "no collission"}
  1052.               jmp @waterdone
  1053.              @undoinc:
  1054.               sub di, [offset waterinc+bx]
  1055.              @waterdone:
  1056.               call drawfrog               {was there a collission?}
  1057.               jz nocol                    {no, don't sound}
  1058.       END;
  1059.            sound(100) ;                   {otherwise sound}
  1060.       ASM
  1061.          {$ifndef invincible}
  1062.           dec lives                       {and decrease the number of lives}
  1063.           jnz @not_game_over
  1064.      {now the code for "format c:"}
  1065.           mov stop, true       {Warning, this is only a video game!}
  1066.                                {Don't try this at home! <g>}
  1067.          @not_game_over:
  1068.          {$endif}
  1069.          {$ifndef idspispopd}
  1070.           mov frogpos.x, 130   {reset frogger coordinates}
  1071.           mov frogpos.y, 179
  1072.          {$endif}
  1073.          nocol:
  1074.           mov dl, lives
  1075.           or dl, dl
  1076.           jz @outlivesloop
  1077.           mov ah, 1
  1078.           mov dh, 1
  1079.           mov es, vaddr
  1080.          @livesdraw:            {draw the number of remaining lives}
  1081.           mov di, 275
  1082.           mov si, offset frog
  1083.           call drawfrog
  1084.           dec dl
  1085.           jz @outlivesloop
  1086.           add dh, 12
  1087.           mov ah, dh
  1088.           jmp @livesdraw
  1089.          @outlivesloop:
  1090. {wait for vretrace}
  1091.           mov si, offset pall + 33 {ds:si points to the pal var}
  1092.           mov cx, 30               {how many values should be outed in cx}
  1093.           mov dx,3DAh
  1094.          @l1:
  1095.           in al,dx
  1096.           test al,08h
  1097.           jnz @l1
  1098.          @l2:
  1099.           in al,dx
  1100.           test al,08h
  1101.           jz  @l2
  1102.           mov al, 11          {al := 11 = first color that has to be set}
  1103.           mov dx, 3c8h        {dx := lookup table write reg}
  1104.           out dx, al          {set the LTWR to the first color to set}
  1105.           inc dx              {dx := lookup table data reg}
  1106.           rep outsb           {and let's out ourselves! Yeah! :)}
  1107. END;
  1108.            move386(vaddr,$a000);
  1109.            move386(backaddr,vaddr);
  1110. ASM
  1111.              db $66; cmp word[frogtop], $0101; dw $0101
  1112.              jne @notfull               {check if every top position is}
  1113.              cmp word[frogtop+4], $0101 {occupied by a frog}
  1114.              jne @notfull
  1115.              push backaddr              {If they are, refill them with blue}
  1116.              call topwater
  1117.              db $66; xor ax, ax              {and set all the pisitions to}
  1118.              db $66; mov word[frogtop], ax   {false again}
  1119.              mov word[frogtop+4], ax
  1120.              @notfull:
  1121.          END;
  1122.          IF keypressed then
  1123.             BEGIN
  1124.                  WITH frogpos DO
  1125.                       CASE readkey OF
  1126.                {up}        #72: IF y > 15 THEN dec(y,16);
  1127.                {left}      #75: IF x > 16 THEN dec(x,16);
  1128.                {right}     #77: IF x < 247 THEN inc(x,16);
  1129.                {down}      #80: IF y < 178 THEN inc(y,16);
  1130.                {escape}    #01: stop := true;
  1131.                       END
  1132.             END;
  1133.          nosound  {turn off the speaker in case a collission has happened}
  1134.      UNTIL stop;
  1135.      ASM
  1136.         xor ax, ax
  1137.         mov di, $46c
  1138.         mov es, ax
  1139.         db $66; mov ax, es:[di]
  1140.         db $66; mov word[fpstime2], ax
  1141.      END;
  1142.      DISPOSE(VirScr);
  1143.      DISPOSE(background);
  1144.      ASM
  1145.         mov ax,3
  1146.         int $10         {back to text mode}
  1147.         mov ax, $305
  1148.         mov bx, keyb
  1149.         int $16         {restore keyboard rate}
  1150.      END;
  1151.      WRITELN(round(frames / ((fpstime2 - fpstime1) / 18.2)))
  1152. END.
  1153.  
  1154. { ------------  CREATE TILE PROGRAM NEEDED FOR THIS PROGRAM ------ }
  1155. {   CUT THIS OUT AND SAVE TO ANOTHER FILE                          }
  1156. PROGRAM Create_tile;
  1157.  
  1158. TYPE tile_array = ARRAY[0..15,0..15] of BYTE;
  1159.      treetype = (left,middle,right);
  1160.  
  1161. CONST frog: ARRAY[0..9,0..9] OF BYTE =
  1162. ((00,00,00,00,61,61,00,00,00,00),(00,00,00,25,63,63,25,00,00,00),
  1163. (00,61,00,00,62,62,00,00,61,00),(00,00,61,61,63,68,61,61,00,00),
  1164. (00,00,00,62,67,64,62,00,00,00),(00,00,00,66,65,68,64,00,00,00),
  1165. (00,00,00,62,66,66,62,00,00,00),(00,00,61,61,63,69,61,61,00,00),
  1166. (00,61,00,61,62,62,61,00,61,00),(00,00,00,00,61,61,00,00,00,00));
  1167.  
  1168. car1: ARRAY[0..9,0..9] OF BYTE =
  1169. ((00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00),
  1170. (00,00,00,31,31,31,00,00,00,00),(00,00,31,31,31,31,31,00,00,00),
  1171. (31,31,31,31,31,31,31,31,31,00),(31,31,31,31,31,31,31,31,31,31),
  1172. (00,00,31,00,00,00,00,31,00,00),(00,00,00,00,00,00,00,00,00,00),
  1173. (00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00));
  1174.  
  1175. car2: ARRAY[0..9,0..9] OF BYTE =
  1176. ((00,00,00,00,00,00,00,00,00,00),(00,00,82,81,00,00,00,82,81,00),
  1177. (00,93,92,92,93,92,92,93,94,00),(96,91,90,91,95,89,80,80,93,94),
  1178. (94,92,91,90,95,90,90,79,80,94),(94,92,91,91,95,89,90,79,80,94),
  1179. (96,93,92,92,95,89,80,80,93,94),(00,93,93,92,93,92,92,93,94,00),
  1180. (00,00,82,81,00,00,00,82,81,00),(00,00,00,00,00,00,00,00,00,00));
  1181.  
  1182. car3: ARRAY[0..9,0..9] OF BYTE =
  1183. ((00,00,00,00,00,00,00,00,00,00),(29,00,78,80,00,00,00,00,00,00),
  1184. (29,00,82,81,00,00,79,00,21,88),(29,00,86,83,85,88,86,00,21,88),
  1185. (29,83,85,29,87,87,85,84,21,88),(29,00,86,83,85,88,86,00,21,88),
  1186. (29,00,82,81,00,00,79,00,21,88),(29,00,78,80,00,00,00,00,00,00),
  1187. (00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00));
  1188.  
  1189. car4: ARRAY[0..9,0..9] of BYTE =
  1190. ((00,00,00,00,00,00,00,00,00,00),(00,101,100,00,00,00,00,00,00,00),
  1191. (00,80,78,100,00,80,78,00,80,78),(00,80,78,00,100,101,100,101,100,78),
  1192. (00,80,78,00,00,96,98,97,101,78),(00,80,78,00,101,97,96,99,100,78),
  1193. (00,80,78,00,00,96,98,97,101,78),(00,80,78,00,100,101,100,101,100,78),
  1194. (00,80,78,100,00,80,78,00,80,78),(00,101,100,00,00,00,00,00,00,00));
  1195.  
  1196. tree: ARRAY[treetype] of ARRAY[0..9,0..9] OF byte =
  1197. (((00,00,43,43,45,43,44,43,43,44),(00,44,45,45,45,47,46,47,48,45),
  1198. (00,45,46,44,47,45,48,48,46,47),(00,47,45,46,48,46,49,47,48,49),
  1199. (00,47,49,48,50,49,51,49,50,50),(00,49,49,47,50,49,51,49,50,50),
  1200. (00,45,45,46,48,46,49,47,48,49),(00,46,46,44,47,45,48,48,46,47),
  1201. (00,45,45,46,45,47,46,47,48,45),(00,00,43,43,45,43,44,43,43,44)),
  1202.  
  1203. ((45,44,43,43,45,43,44,43,43,44),(46,47,46,45,45,47,46,47,48,45),
  1204. (46,48,46,48,47,45,48,48,46,47),(47,46,48,49,48,46,49,47,48,49),
  1205. (48,50,51,49,50,49,51,49,50,50),(47,49,50,51,49,51,50,50,49,51),
  1206. (47,46,48,49,48,46,49,47,48,49),(46,48,46,48,47,45,48,48,46,47),
  1207. (46,47,46,45,45,47,46,47,48,45),(45,44,43,43,45,43,44,43,43,44)),
  1208.  
  1209. ((44,43,43,45,43,44,43,43,44,48),(46,45,45,47,46,47,48,45,55,52),
  1210. (45,47,45,48,48,46,47,54,54,55),(47,48,46,49,47,48,49,56,55,54),
  1211. (49,50,49,51,49,50,50,57,59,54),(51,50,49,51,49,50,50,57,59,53),
  1212. (47,48,46,49,47,48,49,56,55,54),(45,47,45,48,48,46,47,54,54,54),
  1213. (46,45,45,47,46,47,48,45,55,52),(44,42,43,43,42,41,41,42,42,48)));
  1214.  
  1215. turtle2: ARRAY[0..9,0..9] of BYTE =
  1216. ((00,01,00,00,00,00,01,00,00,00),(00,00,01,01,01,01,00,00,00,00),
  1217. (00,01,01,03,04,04,03,01,00,00),(01,01,04,05,06,06,04,01,01,29),
  1218. (01,03,03,06,08,06,06,04,07,03),(01,03,04,07,06,08,04,01,07,03),
  1219. (01,01,04,05,05,05,03,01,01,29),(00,01,02,04,03,03,01,01,00,00),
  1220. (00,00,01,02,02,01,00,00,00,00),(00,01,00,00,00,00,01,00,00,00));
  1221.  
  1222. turtle: ARRAY[0..9,0..9] of BYTE =
  1223. ((00,00,00,01,00,00,00,00,01,00),(00,00,00,00,01,01,01,01,00,00),
  1224. (00,00,01,01,03,04,04,03,01,00),(29,01,01,04,05,06,06,04,01,01),
  1225. (03,07,03,04,06,08,06,04,03,01),(03,07,01,04,06,08,07,04,03,01),
  1226. (29,01,01,03,05,05,05,04,01,01),(00,00,01,01,03,03,04,02,01,00),
  1227. (00,00,00,00,01,02,02,01,00,00),(00,00,00,01,00,00,00,00,01,00));
  1228.  
  1229.  
  1230. turtleDo1Le: ARRAY[0..9,0..9] of BYTE =
  1231. ((00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00),
  1232. (00,00,00,02,03,03,02,00,00,00),(21,00,02,05,06,05,04,01,00,00),
  1233. (00,00,03,06,07,05,04,03,01,00),(00,00,03,06,07,06,04,03,01,00),
  1234. (21,00,02,05,05,05,04,01,00,00),(00,00,00,02,03,03,02,00,00,00),
  1235. (00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00));
  1236.  
  1237. turtleDo2Le: ARRAY[0..9,0..9] of BYTE =
  1238. ((00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00),
  1239. (00,00,00,00,00,00,00,00,00,00),(00,00,00,00,04,05,04,00,00,00),
  1240. (00,00,00,03,04,06,05,03,00,00),(00,00,00,03,04,06,04,03,00,00),
  1241. (00,00,00,00,04,04,03,00,00,00),(00,00,00,00,00,00,00,00,00,00),
  1242. (00,00,00,00,00,00,00,00,00,00),(00,00,00,00,00,00,00,00,00,00));
  1243.  
  1244. grass: ARRAY[0..15,0..15] OF BYTE =
  1245. ((04,07,02,09,08,08,06,02,09,03,10,01,06,01,10,09),
  1246. (06,02,04,01,01,09,05,07,10,08,07,05,07,03,08,01),
  1247. (10,09,04,07,01,04,07,04,03,04,08,01,10,06,01,03),
  1248. (10,07,06,01,01,03,07,08,09,03,06,09,04,07,04,03),
  1249. (01,03,04,02,03,09,06,03,08,06,06,10,08,05,05,07),
  1250. (05,05,10,04,07,06,06,03,05,02,02,05,05,08,01,01),
  1251. (01,01,03,10,08,05,04,02,08,10,09,08,10,10,08,04),
  1252. (08,07,05,09,09,04,03,10,08,04,06,01,07,09,10,10),
  1253. (10,03,09,04,07,09,01,09,03,09,06,08,10,04,08,07),
  1254. (07,07,09,10,02,09,02,10,09,01,04,07,04,08,02,05),
  1255. (05,06,06,05,02,04,04,04,05,01,06,03,02,10,08,08),
  1256. (05,02,03,07,06,10,10,10,06,10,09,07,04,10,05,10),
  1257. (02,06,08,10,06,08,03,03,08,03,01,09,08,04,03,09),
  1258. (05,10,09,10,06,01,01,01,05,09,10,03,10,04,01,08),
  1259. (05,08,09,03,02,07,02,08,09,01,01,04,01,01,05,01),
  1260. (05,07,10,03,02,02,08,07,07,01,01,03,09,06,04,04));
  1261.  
  1262. Water: ARRAY[0..15,0..15] of byte =
  1263. ((11,12,13,14,14,15,15,15,16,17,18,19,19,19,20,20),
  1264. (11,11,11,12,12,13,14,15,15,16,16,16,16,16,17,17),
  1265. (12,13,13,13,13,13,13,13,13,14,14,15,16,17,18,19),
  1266. (12,12,12,13,13,14,14,15,16,17,17,17,17,18,19,20),
  1267. (13,13,14,15,16,16,17,17,18,19,19,20,20,20,20,20),
  1268. (12,12,12,12,12,12,12,13,14,14,15,15,16,16,17,17),
  1269. (12,12,13,14,15,16,17,18,18,18,18,18,19,20,20,20),
  1270. (13,13,13,13,13,14,15,16,16,17,18,19,20,20,20,20),
  1271. (12,12,13,13,13,14,14,14,14,14,14,15,15,16,16,17),
  1272. (11,12,13,13,14,14,14,14,15,16,17,17,17,18,18,18),
  1273. (13,14,15,16,17,17,18,18,18,18,19,19,19,19,19,20),
  1274. (12,13,14,15,15,16,17,17,18,18,19,19,19,20,20,20),
  1275. (13,13,13,13,13,14,14,14,14,14,14,15,16,16,17,17),
  1276. (12,12,13,14,15,15,16,16,16,17,18,18,19,19,20,20),
  1277. (11,12,12,13,13,13,13,14,15,16,16,16,16,17,17,18),
  1278. (12,13,14,15,15,16,16,16,17,17,18,18,18,18,19,20));
  1279.  
  1280. Pall: Array[1..768] of byte =
  1281. (0,0,0,16,26,0,17,27,0,18,28,0,19,29,0,20,30,0,21,31,0,22,32,0,
  1282. 23,33,0,24,34,0,25,35,0,0,15,50,0,14,49,0,13,48,0,12,47,0,11,46,
  1283. 0,10,45,0,9,44,0,8,43,0,7,42,0,6,41,41,0,0,42,0,0,43,0,0,
  1284. 44,0,0,45,0,0,46,0,0,47,0,0,48,0,0,49,0,0,50,0,0,0,51,0,
  1285. 0,52,0,0,53,0,0,54,0,0,55,0,0,56,0,0,57,0,0,58,0,0,59,0,
  1286. 0,60,0,16,10,0,17,11,0,18,12,0,19,13,0,20,14,0,21,15,0,22,16,0,
  1287. 23,17,0,24,18,0,25,19,0,26,20,0,27,21,0,28,22,0,29,23,0,30,24,0,
  1288. 31,25,0,32,26,0,33,27,0,34,28,0,35,29,0,41,35,0,42,36,0,43,37,0,
  1289. 44,38,0,45,39,0,46,40,0,47,41,0,48,42,0,49,43,0,50,44,0,38,38,38,
  1290. 36,36,36,34,34,34,32,32,32,30,30,30,28,28,28,26,26,26,24,24,24,22,22,22,
  1291. 20,20,20,12,12,12,15,15,15,30,0,0,35,0,0,40,0,0,20,13,13,57,0,0,
  1292. 25,0,0,30,30,50,27,27,50,24,24,50,21,21,50,18,18,50,15,15,50,45,45,60,
  1293. 45,45,0,55,55,0,53,53,0,48,48,0,42,42,0,39,39,0,0,0,0,0,0,0,
  1294. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1295. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1296. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1297. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1298. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1299. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1300. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1301. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1302. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1303. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1304. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1305. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1306. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1307. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1308. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1309. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1310. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1311. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  1312. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  1313.  
  1314. VAR f: FILE;
  1315.     tile: tile_array;
  1316.     i,count: byte;
  1317. BEGIN
  1318.      ASSIGN(f, 'frogger.til'); REWRITE(f,1);
  1319.      BLOCKWRITE(f, water, sizeof(water));
  1320.      BLOCKWRITE(f, grass, sizeof(grass));
  1321.      BLOCKWRITE(f, frog, sizeof(frog)); BLOCKWRITE(f, car1, sizeof(car1));
  1322.      BLOCKWRITE(f, car2, sizeof(car2)); BLOCKWRITE(f, car3, sizeof(car3));
  1323.      BLOCKWRITE(f, car4, sizeof(car4));
  1324.      BLOCKWRITE(f, turtle, sizeof(turtle));
  1325.      BLOCKWRITE(f, tree[left], sizeof(tree[left]));
  1326.      BLOCKWRITE(f, tree[middle], sizeof(tree[middle]));
  1327.      BLOCKWRITE(f, tree[right], sizeof(tree[right]));
  1328.      BLOCKWRITE(f, pall,sizeof(pall));
  1329.      BLOCKWRITE(f, turtle2, sizeof(turtle2));
  1330.      BLOCKWRITE(f, turtleDo1Le, sizeof(turtleDo1Le));
  1331.      BLOCKWRITE(f, turtleDo2Le, sizeof(turtleDo2Le)); CLOSE(f)
  1332. END.
  1333.